home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource5 / 349_01 / sss.arc / EX_0401.BAS < prev    next >
Encoding:
BASIC Source File  |  1991-04-09  |  1.2 KB  |  68 lines

  1. ' Program EX_0401.BAS
  2. ' Listing 6B - see documentation in TUTOR.SSS
  3.  
  4. const ARRIVL = 1, TRYBUY = 2, REPLNS = 3
  5. const CUSTMR = 0, GOODS = 1
  6.  
  7. common shared c, ecode
  8.  
  9. declare sub prime ()
  10. declare sub buying ()
  11. declare sub order ()
  12.  
  13. rem $include: 'SSSB.H'
  14.  
  15.   call prime
  16.  
  17.   do
  18.     ecode = NEXTEV
  19.     if ecode > 0 then
  20.       select case ecode
  21.  
  22.       case ARRIVL
  23.              if IDE = CUSTMR then
  24.                CREATE EX(2), 0
  25.                SCHED 0, TRYBUY, IDE
  26.              else
  27.                SCHED 0, REPLNS, IDE
  28.              end if
  29.  
  30.       case TRYBUY
  31.              buying
  32.  
  33.       case REPLNS:
  34.              order
  35.  
  36.       end select
  37.     end if
  38.   loop while ecode > 0
  39.  
  40.   title$ = "  "
  41.   SUMRY sadd(title$)
  42.  
  43. sub buying
  44.   if c = 4 then CREATE TR(5, 7, 9), GOODS
  45.   if c > 0 then c = c - 1 else TALLY 1, 1
  46.   TALLY 2, c
  47.   DISPOS
  48. end sub
  49.  
  50. sub order
  51.   c = c + 12
  52.   TALLY 2, c
  53.   DISPOS
  54. end sub
  55.  
  56. sub prime
  57.   INIQUE 0, 0, 2
  58.   title$ = "Out of stock          "
  59.   INISTA 1, sadd(title$), 0, 0, 0, 0
  60.   title$ = "Ave stock             "
  61.   INISTA 2, sadd(title$), 1, 0, 0, 0
  62.   SIMEND 40
  63.   CREATE EX(2), 0
  64.   c = 15
  65.   TALLY 2, c
  66. end sub
  67.  
  68.